<%@ Page Title="Edit Customer" Language="C#" MasterPageFile="~/Pages/user/userMaster.Master" AutoEventWireup="true" CodeBehind="EditCustomer.aspx.cs" Inherits="WarehouseWebAPP.Pages.user.Edit_Entities.EditCustomer" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .style10
        {
            width: 175px;
        }
        .style13
        {
            width: 109px;
            height: 26px;
        }
        .style14
        {
            width: 106px;
            height: 26px;
        }
        .style15
        {
            height: 26px;
        }
        .style16
        {
            height: 28px;
            width: 295px;
        }
        .style18
        {
            height: 9px;
            width: 295px;
        }
        .style21
        {
            height: 28px;
        }
        .style24
        {
            height: 13px;
        }
        .style25
        {
            width: 100%;
            position: relative;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table class="style25" style="width: 101%; height: 345px;">
        <tr>
            <td class="style24" valign="top">
                <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Italic="False" 
                    Font-Overline="False" Font-Underline="True" ForeColor="#5D7B9D" 
                    Text="Customer Name:" style=""></asp:Label>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <cc1:ComboBox ID="ComboBox1" runat="server" AppendDataBoundItems="True" 
                    AutoCompleteMode="Append" DataSourceID="comboObjectDataSource" 
                    DataTextField="customer_name" DataValueField="customer_num" 
                    DropDownStyle="DropDownList" MaxLength="0">
                </cc1:ComboBox>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <asp:Button ID="Button1" runat="server" BackColor="#FFFBFF" 
 BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px"  
 Font-Names="Verdana" Font-Size="Small" ForeColor="#284775" Text="GO" Width="76px" 
                    onclick="Button1_Click"/>
            </td>
        </tr>
        <tr>
            <td valign="top">
                            <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                                <ContentTemplate>
                                    <asp:Label ID="ErrorLabel" runat="server" BackColor="#FFFFCC" 
                                        ForeColor="Maroon" Height="24px" 
                                        Text="Error: The entity can't be deleted from the following reason: This entity is a FK of other entity." 
                                        Visible="False"></asp:Label>
                                    <asp:DetailsView ID="CustomerDetailsView" runat="server" AllowPaging="True" 
                    AutoGenerateRows="False" CellPadding="4" DataKeyNames="customer_num" 
                    DataSourceID="CustomerObjectDataSource" 
    ForeColor="#333333" GridLines="None" 
                    Height="50px" ondatabound="CustomerDetailsView_DataBound" Width="431px" 
                    onitemdeleting="CustomerDetailsView_ItemDeleting">
                                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                        <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
                                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                        <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
                                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                        <Fields>
                                            <asp:BoundField DataField="customer_num" HeaderText="customer_num" 
                            ReadOnly="True" SortExpression="customer_num" Visible="False" />
                                            <asp:TemplateField HeaderText="Customer ID" SortExpression="customer_id">
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="IDTextBox" runat="server" Text='<%# Bind("customer_id") %>'></asp:TextBox>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                                    ControlToValidate="IDTextBox" ErrorMessage="*"></asp:RequiredFieldValidator>
                                                    <asp:CustomValidator ID="CustomValidator1" runat="server" 
                                    ControlToValidate="IDTextBox" ErrorMessage="Already Exist" 
                                    onservervalidate="CustomValidator1_ServerValidate"></asp:CustomValidator>
                                                </EditItemTemplate>
                                                <InsertItemTemplate>
                                                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("customer_id") %>'></asp:TextBox>
                                                </InsertItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="CustomerLabel" runat="server" Text='<%# Bind("customer_id") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="Customer Name" SortExpression="customer_name">
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="NameTextBox" runat="server" 
                                    Text='<%# Bind("customer_name") %>'></asp:TextBox>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                                    ControlToValidate="NameTextBox" ErrorMessage="*"></asp:RequiredFieldValidator>
                                                    <asp:CustomValidator ID="CustomValidator2" runat="server" 
                                    ControlToValidate="NameTextBox" ErrorMessage="Already Exist" 
                                    onservervalidate="CustomValidator2_ServerValidate"></asp:CustomValidator>
                                                </EditItemTemplate>
                                                <InsertItemTemplate>
                                                    <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("customer_name") %>'></asp:TextBox>
                                                </InsertItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("customer_name") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="Customer Type" SortExpression="customer_type">
                                                <EditItemTemplate>
                                                    <asp:DropDownList ID="DropDownList1" runat="server" 
                                    DataSourceID="TypeObjectDataSource" DataTextField="customer_type" 
                                    DataValueField="customer_type_num" 
                                    SelectedValue='<%# Bind("customer_type") %>'>
                                                    </asp:DropDownList>
                                                    <asp:ObjectDataSource ID="TypeObjectDataSource" runat="server" 
                                    SelectMethod="CustomerTypeGet" 
                                    TypeName="WarehouseWebAPP.code.BLL.CustomerTypeBLL"></asp:ObjectDataSource>
                                                </EditItemTemplate>
                                                <InsertItemTemplate>
                                                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("customer_type") %>'></asp:TextBox>
                                                </InsertItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="TypeLabel" runat="server" Text='<%# Bind("customer_type") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:BoundField DataField="customer_address" HeaderText="Address" 
                            SortExpression="customer_address" />
                                            <asp:TemplateField HeaderText="Phone No." SortExpression="customer_phone">
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("customer_phone") %>'></asp:TextBox>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                                    ControlToValidate="TextBox3" ErrorMessage="*"></asp:RequiredFieldValidator>
                                                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                                    ControlToValidate="TextBox3" ErrorMessage="Invalid Phone No." 
                                    
                                    ValidationExpression="^0[23489]{1}(\-)?[^0\D]{1}\d{6}$|^0(5[012345678]){1}(\-)?\d{7}$"></asp:RegularExpressionValidator>
                                                </EditItemTemplate>
                                                <InsertItemTemplate>
                                                    <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("customer_phone") %>'></asp:TextBox>
                                                </InsertItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("customer_phone") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="E-mail Address" SortExpression="customer_email">
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("customer_email") %>'></asp:TextBox>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                                    ControlToValidate="TextBox4" ErrorMessage="*"></asp:RequiredFieldValidator>
                                                    <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" 
                                    ControlToValidate="TextBox4" ErrorMessage="Invalid E-mail" 
                                    ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
                                                </EditItemTemplate>
                                                <InsertItemTemplate>
                                                    <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("customer_email") %>'></asp:TextBox>
                                                </InsertItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="Label4" runat="server" Text='<%# Bind("customer_email") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                                        </Fields>
                                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                        <EditRowStyle BackColor="#999999" />
                                        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                                    </asp:DetailsView>
                                    <asp:ObjectDataSource ID="comboObjectDataSource" runat="server" 
                                        SelectMethod="CustomerGet" TypeName="WarehouseWebAPP.code.BLL.CustomerBLL">
                                    </asp:ObjectDataSource>
                                    <asp:ObjectDataSource ID="CustomerObjectDataSource" runat="server" 
                                        DeleteMethod="CustomerDelete" 
                                        SelectMethod="CustomerGetByNum" TypeName="WarehouseWebAPP.code.BLL.CustomerBLL" 
                                        UpdateMethod="CustomerUpdate">
                                        <UpdateParameters>
                                            <asp:Parameter Name="customer_id" Type="String" />
                                            <asp:Parameter Name="customer_name" Type="String" />
                                            <asp:Parameter DbType="Guid" Name="customer_type" />
                                            <asp:Parameter Name="customer_address" Type="String" />
                                            <asp:Parameter Name="customer_phone" Type="String" />
                                            <asp:Parameter Name="customer_email" Type="String" />
                                            <asp:Parameter DbType="Guid" Name="customer_num" />
                                        </UpdateParameters>
                                        <SelectParameters>
                                            <asp:ControlParameter ControlID="ComboBox1" DbType="Guid" DefaultValue="%" 
                                                Name="customer_num" PropertyName="SelectedValue" />
                                        </SelectParameters>
                                    </asp:ObjectDataSource>
                                </ContentTemplate>
                                <Triggers>
                                    <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
                                </Triggers>
                            </asp:UpdatePanel>
            </td>
        </tr>
        <tr>
            <td valign="top">
                &nbsp;</td>
        </tr>
        </table>
    </asp:Content>
